﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mtapaevik_paevik", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MtapaevikPaevik))]
    public class MtapaevikPaevikSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMtapaevikPaevik clazz;
        
        public MtapaevikPaevikSerializer(IMtapaevikPaevik clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("paevik_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.PaevikId))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("piirkond");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Piirkond))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("rahuldatud");
            if (clazz.Rahuldatud!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Rahuldatud))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("olek");
            if (clazz.Olek!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Olek))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Olek");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("markus");
            if (clazz.Markus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Markus))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("dok_liik");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.DokLiik))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("kandeliik");
            if (clazz.Kandeliik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Kandeliik))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("esit_kp");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.EsitKp))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("ark");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Ark))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("arinimi");
            if (clazz.Arinimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Arinimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Arinimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("muutus");
            if (clazz.Muutus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Muutus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Muutus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mkuup");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Mkuup))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="paevik_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtapaevik_paevik>paevik_id");
                }
                clazz.PaevikId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("paevik_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>paevik_id", Reader.LocalName);
            }
            if (Reader.LocalName=="piirkond") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtapaevik_paevik>piirkond");
                }
                clazz.Piirkond = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("piirkond")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>piirkond", Reader.LocalName);
            }
            if (Reader.LocalName=="rahuldatud") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Rahuldatud = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("rahuldatud")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>rahuldatud", Reader.LocalName);
            }
            if (Reader.LocalName=="olek") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtapaevik_paevik>olek");
                }
                clazz.Olek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("olek")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>olek", Reader.LocalName);
            }
            if (Reader.LocalName=="markus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Markus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("markus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>markus", Reader.LocalName);
            }
            if (Reader.LocalName=="dok_liik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtapaevik_paevik>dok_liik");
                }
                clazz.DokLiik = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("dok_liik")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>dok_liik", Reader.LocalName);
            }
            if (Reader.LocalName=="kandeliik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Kandeliik = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("kandeliik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>kandeliik", Reader.LocalName);
            }
            if (Reader.LocalName=="esit_kp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtapaevik_paevik>esit_kp");
                }
                clazz.EsitKp = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("esit_kp")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>esit_kp", Reader.LocalName);
            }
            if (Reader.LocalName=="ark") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtapaevik_paevik>ark");
                }
                clazz.Ark = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ark")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>ark", Reader.LocalName);
            }
            if (Reader.LocalName=="arinimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtapaevik_paevik>arinimi");
                }
                clazz.Arinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("arinimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>arinimi", Reader.LocalName);
            }
            if (Reader.LocalName=="muutus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtapaevik_paevik>muutus");
                }
                clazz.Muutus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("muutus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>muutus", Reader.LocalName);
            }
            if (Reader.LocalName=="mkuup") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtapaevik_paevik>mkuup");
                }
                clazz.Mkuup = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("mkuup")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtapaevik_paevik>mkuup", Reader.LocalName);
            }
        }
    }
}
